﻿Function global:Prompt-ForInput {
	param(
		[string]$Caption,
		[string]$Message,
		[System.Collections.Hashtable[]]$FieldDescriptions
	)

	$genericTypeName = 'System.Collections.ObjectModel.Collection`1'
    $genericType = [Type] $genericTypeName
    $closedType = $genericType.MakeGenericType([Type]'System.Management.Automation.Host.FieldDescription') 
    
    $descriptions = [Activator]::CreateInstance($closedType, $false) 
    
    $FieldDescriptions | ForEach-Object {
        $description = [System.Management.Automation.Host.FieldDescription][string]$_.Name
		$description.SetParameterType([Type]$_.Type)
		$description.DefaultValue = $_.DefaultValue
		$description.HelpMessage = $_.HelpMessage
		$description.IsMandatory = $_.IsMandatory
        $descriptions.Add($description)
    }
	
	$host.ui.Prompt($Caption,$Message,$descriptions) 
}
